<template>
  <div>
    <!-- 高度用size -->
    <el-cascader :value="value" size="mini" class="inputW" :options="depts" :props="selectProps" separator="-" @expand-change="handleChange" />
  </div>
</template>

<script>
import { getDepartmentList } from '@/api/department'
import { transList } from '@/utils/index'
export default {
  props: {
    value: {
      type: Number,
      default: 2
    }
  },
  data() {
    return {
      depts: [],
      selectProps: {
        value: 'id',
        label: 'name'
      }
    }
  },
  created() {
    this.getDepartmentList()
  },
  methods: {
    async getDepartmentList() {
      this.depts = transList(await getDepartmentList())
    },
    handleChange(node) {
      this.$emit('input', node[node.length - 1])
    }
  }
}
</script>

<style scoped lang="scss">

      .inputW {
        width: 380px
      }

</style>
